package com.shop2cn.iapi.productcategory.testcase;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.productcategory.parameter.BrandDto;
import com.shop2cn.iapi.productcategory.parameter.BrandInfo;
import com.shop2cn.iapi.productcategory.parameter.GetBrandInfoByIdBean;
import com.shop2cn.iapi.productcategory.service.GetBrandInfoByIdCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.database.mongo.BuyerProductShop2cnWapper;
import com.ymttest.database.sqlwapper.YmtProductBrandWapper;
/**
*查询品牌详细信息（后台）
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetBrandInfoById{
	private static GetBrandInfoByIdBean getbrandinfobyidBean;
	private static GetBrandInfoByIdCall getbrandinfobyidCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询品牌详细信息（后台）");
	}

	@Before
	public void caseUp() {
		getbrandinfobyidBean=new GetBrandInfoByIdBean();
		getbrandinfobyidCall=new GetBrandInfoByIdCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getbrandinfobyidCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetBrandInfoById_001() {
		Logger.start(true,"查询品牌详细信息（后台）");
		try {
			BuyerProductShop2cnWapper pbinfow = new BuyerProductShop2cnWapper();
			ArrayList<Map> list = pbinfow.getProductBrandInfoById(21570);
			Map map = list.get(0);
			String BrandId = map.get("BrandId").toString();
			getbrandinfobyidBean.setBrandId(Integer.valueOf(BrandId));
			getbrandinfobyidCall.setData(getbrandinfobyidBean);
			getbrandinfobyidCall.callService();			
			Logger.verifyEquals("200", getbrandinfobyidCall.getString("Code"), "验证Code");
			BrandInfo Brand=(BrandInfo) FormatUtil.GSONToObject(getbrandinfobyidCall.getJsonObject().get("Data").getAsJsonObject().get("BrandInfo").toString(), BrandInfo.class);
			Logger.verifyEquals(map.get("BrandId"), Brand.getId(), "验证id");
			Logger.verifyEquals(map.get("KeyWord"), Brand.getKeyWord(), "验证KeyWord");
			Logger.verifyEquals(map.get("BrandEnName"), Brand.getEnName(), "验证BrandEnName");
			Logger.verifyEquals(map.get("CountryId"), Brand.getCountryId(), "验证CountryId");
			Logger.verifyEquals(map.get("BrandLogoUrl"), Brand.getLogoUrl(), "验证LogoUrl");
			Logger.verifyEquals(map.get("BrandBannerUrl"), Brand.getBannerUrl(), "验证BrandBannerUrl");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}